package trash;

import com.adxon.data.Figure;
import com.google.appengine.api.images.*;

public class Thumb extends Figure{
	public Thumb(){
	}
	public byte[] getBits(){
		bt=getBits("bt",bt);
		if(bt==null){
			byte[] o=getBits("bo",bo);
			if(o!=null){
				Image m=ImagesServiceFactory.makeImage(o);
				float w=m.getWidth();
				float h=m.getHeight();
				float l,t,r,b;
				int k;
				if(w>=h){
					k=(int)(w*96/h);
					l=0;
					r=h/w;
					t=0;
					b=1;
				}else{
					k=(int)(h*96/w);
					l=0;
					r=1;
					t=0;
					b=w/h;
				}
				Transform z=ImagesServiceFactory.makeResize(k,k);
				m=ImagesServiceFactory.getImagesService().applyTransform(z,m);
				z=ImagesServiceFactory.makeCrop(l,t,r,b);
				m=ImagesServiceFactory.getImagesService().applyTransform(z,m,jpeg());
				bt=m.getImageData();
				tm=0;		// set modified flag
			}
		}
		return bt;
	}
}